package com.jiangdg.demo;

import android.content.Context;
import android.content.SharedPreferences;

public class LanguagePreference {

    private static final String PREFS_NAME = "settings";
    private static final String LANGUAGE_KEY = "language";

    public static void saveLanguagePreference(Context context, String languageCode) {
        SharedPreferences preferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        preferences.edit().putString(LANGUAGE_KEY, languageCode).apply();
    }

    public static String loadLanguagePreference(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        return preferences.getString(LANGUAGE_KEY, "en"); // 默认英文
    }
}
